-
Notifications
You must be signed in to change notification settings - Fork 247
feat: block Pruning #2984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: block Pruning #2984
Conversation
|
The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).
|
|
Claude finished @pthmas's task in 2m 5s —— View job Code Review: Block Pruning ImplementationReview Checklist
SummaryThis PR implements height-based pruning for ev-node's block data store. The implementation is generally well-designed with good idempotent tracking, comprehensive testing, and thoughtful integration across multiple stores. However, there are important concerns about running pruning synchronously in the critical path and some edge cases that need attention. 1. Code Quality & Architecture✅ Strengths
|
| Priority | Issue | Impact | Recommendation |
|---|---|---|---|
| 🔴 High | Synchronous pruning in critical path | Block production delays | Move to background or rate-limit |
| 🟡 Medium | Silent pruning failures | Unbounded disk growth | Add metrics and health checks |
| 🟡 Medium | Missing integration tests | Unknown real-world behavior | Add E2E pruning tests |
| 🟡 Medium | No context cancellation in loops | Slow shutdown during pruning | Add ctx.Done() checks |
| 🟢 Low | go-header time-based window drift | Potential misalignment | Document assumption |
Recommendations for Follow-up PRs
- Async pruning (High priority): Refactor to run pruning in a background worker
- Monitoring (High priority): Add Prometheus metrics for pruning operations
- Integration tests (Medium priority): Verify end-to-end pruning behavior
- Operational docs (Medium priority): Add pruning guide for operators
Final Verdict
This is a well-engineered feature with solid fundamentals:
- ✅ Clean architecture with optional interfaces
- ✅ Idempotent and resumable design
- ✅ Comprehensive unit test coverage
- ✅ Proper error handling at the code level
However, the synchronous execution in the critical path is a significant concern that should be addressed before merging to production or documented as a known limitation with plans to refactor.
Approval Status: Approve with recommendations
- Safe to merge if synchronous pruning latency is acceptable for expected workloads
- Strongly recommend prioritizing async pruning in a follow-up PR
- Add integration tests and monitoring before deploying to production
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given we have a lot of different stores and keys. Are we planning to prune as well:
- metadatas?
- go-header store? (there are settings to be looked at)
- execution/evm store (https://github.com/evstack/ev-node/blob/main/execution/evm/store.go)
(and eventually ev-abci store)
It will be inconsistent if we don't allow height pruning of all those stores (at once).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this PR to prune metadats, go-header store and evm store ✅
I'm happy to work on prunning ev-abci next, but I would probably do it in another PR to prevent this PR from getting too big if that's ok.
3e1e8e0 to
ed66fe6
Compare
Overview
/h/{height},/d/{height},/c/{height},/i/{hash}up to a target height.height → DA heightmapping) for pruned heights./s/{height}(state),/t(current height), and global metadata keys untouched.last-pruned-block-heightmetadata key so pruning is monotonic and idempotent.store.PruneBlockssynchronously.PruningKeepRecent * BlockTimeso header/data retention matches ev-node’s window.EVMStoreexposesPruneExecMetato delete per-heightExecMetaentries up to a target height.ExecMetaPrunerinterface, and the block executor calls it from the same pruning hook.Config
New node config fields / flags:
--evnode.node.pruning_enabled--evnode.node.pruning_keep_recent--evnode.node.pruning_intervalPruning actually runs only when all three are set to non-trivial values (enabled, keep_recent > 0, interval > 0).
Design trade-offs
Runs in the critical path:
Pruning is called synchronously in
produceBlock. On pruning heights, block production will incur extra latency proportional to the amount of data pruned and underlying storage performance.Best-effort pruning:
If pruning fails, we log the error but do not fail the block. This avoids halting the node but means disk usage can grow silently if pruning keeps failing; operators will need to watch logs/metrics.
Scope:
This PR prunes ev-node’s own store, the go-header store, and EVM
ExecMeta. Pruning of ABCI state (ev-abci) is out of scope and will be added in a follow-up once ev-abci exposes its own pruning API.